package com.example.tourstor;

import android.app.Activity;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class HelpPlanActivity extends AppCompatActivity {

    private static final String TAG = "HelpPlanActivity";
    private TextView title;
    private EditText Lmoney;
    private Button title_btn_left,title_btn_right,loan;

    private float lmoney,limoney,lrate;
    private String name;

    private Thread t;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_help_plan);
        setTitle();

        loan=findViewById(R.id.loan);
        Lmoney=findViewById(R.id.Lmoney);

        final SharedPreferences sharedPreferences=getSharedPreferences("Cname", Activity.MODE_PRIVATE);
        //name=sharedPreferences.getString("Cname",null);
        name="41623060";
        Log.i(TAG, "MyPlanActivity2: 登录名是："+name);

        if(name!=null){

            loan.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    lmoney= Float.parseFloat(Lmoney.getText().toString());
                    t=new Thread(new Runnable() {
                        @Override
                        public void run() {
                            //将信息插入数据库

                        }
                    });
                    t.start();

                }
            });

        }else {
            Toast.makeText(HelpPlanActivity.this,"请先登录",Toast.LENGTH_LONG).show();
        }
    }
    public void setTitle(){
        title = findViewById(R.id.title_text);
        title.setText("助力计划");
        title_btn_left = findViewById(R.id.title_btn_left);
        title_btn_right=findViewById(R.id.title_btn_right);
        title_btn_left.setText("");
        title_btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        title_btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
